﻿using System;

namespace PublicTransportEnabler.net.Model
{
    [Serializable]
    public class Point : EquatableBase<Point>
    {
        public Point(float lat, float lon)
        {
            Lat = (int) Math.Round(lat*1E6);
            Lon = (int) Math.Round(lon*1E6);
        }

        public Point(int lat, int lon)
        {
            Lat = lat;
            Lon = lon;
        }

        public int Lat { get; private set; }
        public int Lon { get; private set; }

        public override string ToString()
        {
            return "[" + this.Lat + "/" + this.Lon + "]";
        }

        public override bool Equals(Point other)
        {
            if (this.Lat != other.Lat)
                return false;
            if (this.Lon != other.Lon)
                return false;
            return true;
        }

        public override int InstanceGetHashCode()
        {
            return this.Lat + 27*this.Lon;
        }
    }
}